﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for clsQtDeThi
/// </summary>
public class clsQtDeThi
{
    DataClassesDataContext qldt = new DataClassesDataContext();
	public clsQtDeThi()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public int thoigian(string madt)
    {
        int time = (from p in qldt.tbl_QUYTACDETHIs
                    from q in qldt.tbl_DETHIs
                    where p.MaQT == q.MaQT && q.MaDT == madt
                    select p.Thoigian).Single();
        return time;
        
    }
    public void ThemmoiQTDT(string maquytac, int soCH, int soKho, int soTB, int soDe, int thoigian)
    {
        tbl_QUYTACDETHI qtde = new tbl_QUYTACDETHI();
        qtde.MaQT = maquytac;
        qtde.SoCH = soCH;
        qtde.Kho = soKho;
        qtde.TB = soTB;
        qtde.De = soDe;
        qtde.Thoigian = thoigian;
        qldt.tbl_QUYTACDETHIs.InsertOnSubmit(qtde);
        qldt.SubmitChanges();

    }
    public void XoaQTde(string maqtac)
    {
        var qt = from p in qldt.tbl_QUYTACDETHIs
                 where p.MaQT == maqtac
                 select p;
        qldt.tbl_QUYTACDETHIs.DeleteAllOnSubmit(qt);
        qldt.SubmitChanges();


    }
    public void SuaQTde(string maqtac, int soCH, int soKho, int soTB, int soDe)
    {
        var suaqt = (from p in qldt.tbl_QUYTACDETHIs
                     where p.MaQT == maqtac
                     select p).Single();
        suaqt.SoCH = soCH;
        suaqt.Kho = soKho;
        suaqt.TB = soTB;
        suaqt.De = soDe;
        qldt.SubmitChanges();
    }
    public int KTTrungMa(string maqt)
    {
        if (qldt.tbl_QUYTACDETHIs.Any(o_ql => o_ql.MaQT == maqt))
        {
            return 1;
        }
        return 0;

    }
}
